import java.util.HashSet;
import java.util.Set;

public class Service {
	private String id;
	private Set<Concept> inputConcepts;
	private Set<Concept> outputConcepts;
	
	/*
	 * Constructors.
	 */
	public Service() {}
	
	public Service(String id) {
		this.id = id;	
		inputConcepts = new HashSet<Concept>();
		outputConcepts = new HashSet<Concept>();
	}
	
	/*
	 * Getters and setters.
	 */

	public void setId(String id) {
		this.id = id;
	}
	public String getId() {
		return id;
	}
	
	public Set<Concept> getInputConcepts() {
		return inputConcepts;
	}
		
	public Set<Concept> getOutputConcepts() {
		return outputConcepts;
	}
	
	public void addInputConcept(Concept c) {
		inputConcepts.add(c);	
	}
	
	public void addOutputConcept(Concept c) {
		outputConcepts.add(c);
	}
	
	/*
	 * Overridden toString() function. Displays all attributes of the object.
	 */
	public String toString() {
		String s = "";
		s += "ID: " + id + "\n";
		s += "Input concepts: " + "\n";
		for (Concept c : inputConcepts)
			s += "\t" + c.getName() + "\n";
		s += "Output concepts: " + "\n";
		for (Concept c : outputConcepts)
			s += "\t" + c.getName() + "\n";
		
		return s;			
	}
	
	@Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj == null || obj.getClass() != this.getClass()) {
            return false;
        }

        Service other = (Service) obj;
        return id == other.id;
    }
   
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + id.hashCode();
        return result;
    }

}
